package com.neuedu.collection.MyCollectionsDemo;

import java.util.*;

public class MyCollections {
    public static void main(String[] args) {
//        Set set  = new TreeSet();
//        set.add(1);
//        set.add(13);
//        set.add(5);
//        //   //数值类型可以直接比较
//        System.out.println(Collections.max(set));

        Set<Student>   stu =  new HashSet<>();
        Student  s1= new Student("张三",18);
        stu.add(s1);
        stu.add(new Student("李四",28));
        stu.add(new Student("wangwu",68));
        System.out.println(stu);
        System.out.println( Collections.max(stu) );

        List  list= new ArrayList();
        list.add(s1);
        list.add(new Student("李四",28));
        list.add(new Student("wangwu",68));
        System.out.println(list);
        System.out.println(Collections.max(list));

        List<Teacher>  list2 = new ArrayList();
        list2.add(new Teacher("黄老邪",88));
        list2.add(new Teacher("洪七公",78));
        list2.add(new Teacher("欧阳锋",68));
        //Teacher maxTeacher = Collections.max(teachers, ( o1,  o2) ->   o1.getAge() - o2.getAge() );
        Object   obj = Collections.max(list2,(o1,o2)-> o1.getAge()-o2.getAge());
        System.out.println( obj  );
        //sort排序
        System.out.println("+++++++++++++++++++++++++sort+++++++++++++++++++++++++++++++++");
        List<Integer> list3 = Arrays.asList(10,20,30,6,4,20,4);
        Collections.sort(list3);
        list3.forEach(System.out::println);
        System.out.println("==================================");
        Collections.sort(list3,(o1,o2) -> o2-o1);
        list3.forEach(System.out::println);

        List<Teacher> dest = new ArrayList();
        dest.add(null);
        dest.add(null);
        dest.add(null);
        dest.add(null);
        dest.add(null);
        dest.add(null);

        Collections.copy(dest,list2);
        dest.forEach(System.out::println);
        Collections.fill(dest,new Teacher("未定义",0));
        dest.forEach(System.out::println);


    }
}
